Skip to content

fix(check): distinguish permission-denied from boot chain failure#33

Merged
rocketman-code merged 1 commit intomainfrom
fix/check-permission-denied
Apr 15, 2026
Merged

fix(check): distinguish permission-denied from boot chain failure#33
rocketman-code merged 1 commit intomainfrom
fix/check-permission-denied

Conversation

@rocketman-code
Copy link
Copy Markdown
Owner

Closes #14.

Summary

Running atomic-rollback check as non-root on Fedora hits permission-denied reading /boot/efi/EFI/fedora/grub.cfg (root-readable only). Before this change, the tool reported "Boot chain has problems" and exited 1, conflating "cannot verify" with "found problems."

Two semantically distinct facts now have distinct representations:

  • New GrubContextError { PermissionDenied { path }, Other(String) } preserves io::ErrorKind at the source
  • New BootStatus::Inaccessible { reason, hint } variant distinct from Fail
  • Main's Check handler prints "Cannot verify boot chain: ..." with hint, exits 3 (new code for "could not verify")
  • Downstream callers (kernel_hook, rollback, check::gate) get context-appropriate handling

Exit codes

  • 0: Pass
  • 1: Fail (real boot-chain problem)
  • 2: Warn (valid with warnings)
  • 3: Inaccessible (could not verify; try sudo) — NEW

Scripts relying on exit codes can now tell the three failure modes apart.

Test plan

  • cargo build --release clean (build.rs drift check passes)
  • cargo test --release all 23 tests pass
  • VM (Fedora 43 btrfs) as root: atomic-rollback check exits 0 (Pass)
  • VM as non-root user: atomic-rollback check exits 3, reports "Cannot verify boot chain: permission denied reading /boot/efi/EFI/fedora/grub.cfg", hints "Run: sudo atomic-rollback check", does NOT say "Boot chain has problems"
  • CHANGELOG.md regenerated via cargo run -p changelog > CHANGELOG.md, matches source-of-truth

Running `atomic-rollback check` as non-root on Fedora hits
permission-denied reading /boot/efi/EFI/fedora/grub.cfg (root-readable
only on Fedora). Before this change, the tool reported "Boot chain has
problems" and exited 1, conflating "we could not verify" with
"we found problems." Scripts relying on exit codes could not tell
apart the two.

Two semantically distinct facts now have distinct representations:

- grub.rs: new GrubContextError enum with PermissionDenied and Other
  variants. The io::ErrorKind from fs::read_to_string is preserved at
  the source instead of collapsing into a String.
- check.rs: new BootStatus::Inaccessible { reason, hint } variant.
  verify_bootable and verify_snapshot_bootable map PermissionDenied to
  Inaccessible, Other to Fail.
- main.rs Check: new match arm prints "Cannot verify boot chain:
  <reason>" with hint, exits 3.
- kernel_hook.rs: treats Inaccessible as a warning (log, do not abort
  kernel-install).
- rollback.rs: treats Inaccessible as Fail (abort rather than proceed
  with an unverified snapshot).
- check.rs gate: treats Inaccessible as Fail (migration runs as root;
  reaching this branch is unexpected and should fail safe).

Exit codes:
- 0: Pass
- 1: Fail (real boot-chain problem)
- 2: Warn (valid with warnings)
- 3: Inaccessible (could not verify; try sudo)

Verified on Fedora 43 VM: as root exits 0, as non-root exits 3 with
"permission denied reading /boot/efi/EFI/fedora/grub.cfg" and a
"Run: sudo atomic-rollback check" hint. The "Boot chain has problems"
message no longer fires for non-root.

Closes #14.
@rocketman-code rocketman-code merged commit ffe60f9 into main Apr 15, 2026
6 checks passed
@rocketman-code rocketman-code deleted the fix/check-permission-denied branch April 15, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: check reports boot problems when ESP grub.cfg is unreadable

1 participant